package cn.edu.scau.cmi.liangzaoqing.copyFileByDirectory;

import static org.junit.jupiter.api.Assertions.*;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class BasePropertyEditorTestCase {
	private String projectName;
	private String cmiPages;
	private String javaPackage;
	private String sourceProjectDirectionary;
	private String targetProjectDirectionary;
	private String cmiDomain;
	private String cmiDao;
	private String cmiController;
	private String cmiRestController;
	private String cmiPagination;
	private String cmiPropertyEditor;
	private String cmiService;
	private String cmiUtil;
	private String resource;
	private String resourcesBundles;
	private String cmiBase;
	private String cmiBaseBean;
	private String cmiBasePropertyEditor;
	private String cmiBaseServiced;
	private String cmiBaseController;
	private String cmiBaseRestController;
//	TODO　测试完成后使用Spring依赖注入
	@BeforeEach
	void setUp() throws Exception {
		Properties properties = new Properties();
		InputStream input = new BufferedInputStream(new FileInputStream("E:\\Workspace\\git\\scauCmiScaffolding\\test\\copy\\file.properties"));
		properties.load(input);
//		基本属性部分
		sourceProjectDirectionary = properties.getProperty("sourceProjectDirectionary");
		targetProjectDirectionary = properties.getProperty("targetProjectDirectionary");
		projectName = properties.getProperty("projectName");
		javaPackage = properties.getProperty("javaPackage");
//		Java基础类部分
		cmiBase = properties.getProperty("cmiBase");
		cmiBaseBean = properties.getProperty("cmiBaseBean");
		cmiBasePropertyEditor = properties.getProperty("cmiBasePropertyEditor");
		cmiBaseServiced = properties.getProperty("cmiBaseServiced");
		cmiBaseController = properties.getProperty("cmiBaseController");
		cmiBaseRestController = properties.getProperty("cmiBaseRestController");
		cmiUtil = properties.getProperty("cmiUtil");
//		java核心类部分
		cmiController = properties.getProperty("cmiController");
		cmiRestController = properties.getProperty("cmiRestController");
		cmiDao = properties.getProperty("cmiDao");
		cmiDomain = properties.getProperty("cmiDomain");
		cmiPagination = properties.getProperty("cmiPagination");
		cmiPropertyEditor = properties.getProperty("cmiPropertyEditor");
		cmiService = properties.getProperty("cmiService");
		

//		资源部分		
		resource = properties.getProperty("resource");
		resourcesBundles = properties.getProperty("resourcesBundles");
		
//		页面部分
		cmiPages = properties.getProperty("cmiPages");

//		properties.list(System.out);

//		System.out.println(cmiPages);
	}

	
	@Test
	void copyBasePropertyEditor() throws IOException {
		String srcBasePropertyEditorDirectionary=sourceProjectDirectionary+"/"+"cmi"+"/"+javaPackage+"/"+projectName+"/"+cmiBasePropertyEditor;
		String destBasePropertyEditorDirectionary=targetProjectDirectionary+"/"+"cmi"+"/"+javaPackage+"/"+projectName+"/"+cmiBasePropertyEditor;
		FileUtils.copyDirectory(new File(srcBasePropertyEditorDirectionary), new File(destBasePropertyEditorDirectionary));
		System.out.println(srcBasePropertyEditorDirectionary);
		System.out.println(destBasePropertyEditorDirectionary);
		System.out.println("复制BasePropertyEditor文件成功！！！");
	}
	

}
